<template>
    <view v-if="show">
        <view class="shop-btn" @tap="toLink">
            <text>优选</text>
            <text>订单</text>
        </view>

        <view class="shop-kefu-btn" @tap="toKFLink">
            <image src="/static/icon/kefu.png" />
        </view>
    </view>
</template>

<script>
import { mapGetters } from 'vuex';
import moment from 'moment';
export default {
    props: {
        current: {
            type: Object,
            default: () => {
                return {};
            }
        }
    },
    computed: {
        ...mapGetters(['userInfo', 'app']),
        show() {
            return this.current.value == 'shop';
        }
    },
    created() {
        (function(w, d, n, a, j) {
            w[n] =
                w[n] ||
                function() {
                    (w[n].a = w[n].a || []).push(arguments);
                };
            j = d.createElement('script');
            j.async = true;
            j.src = 'https://qiyukf.com/script/e2047b4addc24634df6b8ee6bc56725c.js';
            d.body.appendChild(j);
        })(window, document, 'ysf');
    },
    methods: {
        toLink() {
            this.$hmt.push('优选订单点击事件', '打开优选订单');

            this.$service.common.selfmallLogin().then(res => {
                res.expires_time = moment(res.expires_time).unix();
                this.$href(
                    `http://mall.xmonecode.com/order/list/0?token=${res.token}&expires_time=${res.expires_time}`
                );
            });
        },

        toKFLink() {
            window.ysf('open');
        }
    }
};
</script>

<style lang="scss" scoped>
.shop-btn,
.shop-kefu-btn {
    position: fixed;
    right: 30rpx;
    z-index: 999;
    border-radius: 100rpx;
    height: 80rpx;
    width: 80rpx;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1rpx solid #eee;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.shop-btn {
    bottom: 350rpx;
    background-color: #666;
    color: #fff;
}

.shop-kefu-btn {
    bottom: 250rpx;
    border-color: #fff;
    background-color: #fff;

    image {
        height: 60rpx;
        width: 60rpx;
    }
}
</style>
